package flexo.gui.flat;

import flexo.graphic.entity.Quad;
import flexo.math.Coords;
import flexo.scene.Node;

public class Cursor extends flexo.gui.Cursor
{
	protected Quad hQuad;
	protected Quad vQuad;
	protected static final float invWidth = 8;
	
	public Cursor(Coords size, Coords hotspot, String material)
	{
		super(size, hotspot);
		flexo.graphic.GraphicSystem gs = (flexo.graphic.GraphicSystem)flexo.Kernel.getSystem(flexo.graphic.GraphicSystem.ID);
		hQuad = gs.addQuad(this.size.x, this.size.y / invWidth);
		vQuad = gs.addQuad(this.size.x / invWidth, this.size.y);
		hQuad.setMaterial(material);
		vQuad.setMaterial(material);
	}
	
	@Override
	public boolean attachTo(Node n)
	{
		boolean result = super.attachTo(n);
		if (result)
		{
			hQuad.attachTo(this.hotspotNode);
			vQuad.attachTo(this.hotspotNode);
		}
		return result;
	}
	
	public void deattachFrom(Node n)
	{
		hQuad.deattachFrom(this.hotspotNode);
		vQuad.deattachFrom(this.hotspotNode);		
		super.deattachFrom(n);		
	}
}
